//
//  FTSideViewController.m
//  FaceTo
//
//  Created by 姚冬元 on 2017/6/20.
//  Copyright © 2017年 chengbangming. All rights reserved.
//

#import "FTSideViewController.h"
#import "FTSideViewCell.h"
#import "FTSideHeaderView.h"
#import "FTSideTopViewCell.h"
#import "FTSideMidViewCell.h"

@interface FTSideViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;

@property (nonatomic, strong) NSArray *titleArray;

@property (nonatomic, strong) NSArray *imgArray;

@end

@implementation FTSideViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = WhiteColor;
    
    _titleArray = @[@"", @"课程表", @"校园卡", @"More>>", @"", @"关于软件", @"设置"];
    _imgArray = @[@"", @"sideschedule", @"sidecard", @"sidemore", @"", @"sideabout", @"sidesetting"];
    
    [self initUI];
}

- (void)initUI
{
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, kSCREEN_WIDTH*0.3+40, kSCREEN_WIDTH*0.3, kSCREEN_HEIGHT) style:UITableViewStylePlain];
    _tableView.backgroundColor = WhiteColor;
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = NO;
    [self.view addSubview:_tableView];
    
    FTSideHeaderView *headerView = [[FTSideHeaderView alloc] init];
    headerView.frame = CGRectMake(0, 0, kSCREEN_WIDTH*0.3, kSCREEN_WIDTH*0.3+40);
    [self.view addSubview:headerView];
    
    UIButton *exitBtn = [[UIButton alloc] init];
    exitBtn.frame = CGRectMake(kSCREEN_WIDTH*0.3/2-40, kSCREEN_HEIGHT-60, 80, 40);
    [exitBtn setTitle:@"退出" forState:UIControlStateNormal];
    [exitBtn setImage:[UIImage imageNamed:@"sideexit"] forState:UIControlStateNormal];
    [exitBtn setTitleColor:FontColor forState:UIControlStateNormal];
    exitBtn.titleLabel.font = LPFont(12);
    [self.view addSubview:exitBtn];
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 7;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row == 0) {
        return 35;
    }
    else if (indexPath.row == 4) {
        return 20;
    }
    return 65;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        
        static NSString *identifier = @"cell0";
        
        FTSideTopViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        
        if (cell == nil) {
            cell = [[FTSideTopViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        }
        
        cell.selectionStyle = NO;
        
        return cell;

    }
    else if (indexPath.row == 4) {
     
        static NSString *identifier = @"cell1";
        
        FTSideMidViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        
        if (cell == nil) {
            cell = [[FTSideMidViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        }
        
        cell.selectionStyle = NO;
        
        return cell;
    }
    else {
        static NSString *identifier = @"cell";
        
        FTSideViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        
        if (cell == nil) {
            cell = [[FTSideViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        }
        cell.imgView.image = [UIImage imageNamed:_imgArray[indexPath.row]];
        cell.titlelbl.text = _titleArray[indexPath.row];
        cell.selectionStyle = NO;
        
        return cell;
    }
}


@end
